package com.hqyj.listener;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 项目:rabbitmq-230301-summer
 * 描述:
 * 时间:2023/8/3 14:28
 * 作者:admin
 * 版本:1.0
 **/
@Component
@Slf4j
public class TestFanoutListener {


    @RabbitListener(queues = "queue01")
    public void getListener(Channel channel, Message message, Map<String,Object> map) {
        log.info("queue01在消费消息");
        log.info("message消息{}",message.toString());
        log.info("消息的编号:{}," +
                        "消息的发送时间:{}," +
                        "接收消息的交换机:{}",
                message.getMessageProperties().getDeliveryTag(),
                message.getMessageProperties().getTimestamp(),
                message.getMessageProperties().getReceivedExchange()
        );
        log.info("msg{}",map.get("msg"));

    }

    @RabbitListener(queues = "queue02")
    public void getListeners(Channel channel, Message message, Map<String,Object> map) {
        log.info("queue02在消费消息");
        log.info("message消息{}",message.toString());
        log.info("消息的编号:{}," +
                        "消息的发送时间:{}," +
                        "接收消息的交换机:{}",
                message.getMessageProperties().getDeliveryTag(),
                message.getMessageProperties().getTimestamp(),
                message.getMessageProperties().getReceivedExchange()
        );
        log.info("msg{}",map.get("msg"));

    }
}
